package com.itheima.thread02;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class Demo01 {
    public static void main(String[] args) {
        Thread t1 = new Thread(new FutureTask<>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                for (int i = 0; i < 100; i++) {
                    System.out.println(Thread.currentThread().getName() + "执行到了" + i);
                }
                return "干完了";
            }
        }));
        t1.setName("小蔡");
        t1.setPriority(10);
        Thread t2 = new Thread(new FutureTask<>(() -> {
            for (int i = 0; i < 100; i++) {
                String name = Thread.currentThread().getName();
                System.out.println(name + "执行到了" + i);
            }
            return "干完了";
        }));
        t2.setName("小黄");
        t2.setPriority(1);
        t1.start();
        t2.start();
    }


}
